import random

# Python对象实现示例方法__call__,使Python对象表现得像函数
class BingoCage(object):
	def __init__(self, items):
		self._items = list(items)
		random.shuffle(self._items)

	def pick(self):
		try:
			return self._items.pop()
		except IndexError:
			raise LookupError('pick from empty BingoCage')

	def __call__(self):
		return self.pick()

bingo = BingoCage(range(3))
bingo.name = 'aaa'
print(dir(bingo))

# print(dict(bingo))
print(bingo.pick())
print(bingo())
print(callable(bingo))
